package com.seafwg.xml.dao.impl;

import com.seafwg.xml.dao.AccountDao;
import org.springframework.jdbc.core.JdbcTemplate;


/**
 * @Author seafwg
 * @Date 2022/3/13 12:14 上午
 * @Version 1.0
 * @description xxx
 */

public class AccountDaoImpl implements AccountDao {

    // @Autowired
    // private JdbcTemplate jdbcTemplate;
    private JdbcTemplate jdbcTemplate;
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    // 账户增加money
    @Override
    public void addAccount(String addPerson, double money) {
        jdbcTemplate.update("update account set money = money + ? where name = ?", money, addPerson);
    }

    // 账户减少money
    @Override
    public void divAccount(String divPerson, double money) {
        jdbcTemplate.update("update account set money = money - ? where name = ?", money, divPerson);
    }
}
